﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class TaoBaoApi_SessionKeySettings : System.Web.UI.Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = BLL.Common.GetWSMThemes();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            Bind();
    }
    void Bind()
    {
        string sql = "select mid,appkey,appcertcode,field1,field2 from tb_appcode where len(field2)>0";
        DataSet ds = DBUtility.SqlHelper.Query(DBUtility.SqlHelper.LocalSqlServer, sql);
        gvList.DataSource = ds.Tables[0];
        gvList.DataBind();
    }
    protected void gvList_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        if (e.RowIndex != -1)
        {
            int mid = SiteCommon.Common.GetInt(this.gvList.DataKeys[e.RowIndex].Value);
            string sessionKey = ((TextBox)gvList.Rows[e.RowIndex].Cells[4].Controls[0]).Text;
            string sql = string.Format("update tb_appcode set field1='{0}' where mid={1}", sessionKey, mid);
            DBUtility.SqlHelper.ExecuteNonQuery(DBUtility.SqlHelper.LocalSqlServer, new string[] { sql });
        }
        this.gvList.EditIndex = -1;
        Bind();
    }
    protected void gvList_RowEditing(object sender, GridViewEditEventArgs e)
    {
        this.gvList.EditIndex = e.NewEditIndex;
        Bind();
    }
    protected void gvList_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        this.gvList.EditIndex = -1;
        Bind();
    }
}
